package br.com.gscorp.bankLion.service;

import java.security.SecureRandom;
import java.util.Calendar;
import java.util.Random;
import java.util.UUID;

import org.springframework.stereotype.Service;

@Service
public class UsuarioService {

	public String gerarSenha(){
		char[] characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
		Random random = new SecureRandom();
		char[] result = new char[6];
		for (int i = 0; i < result.length; i++) {
			// picks a random index out of character set > random character
			int randomCharIndex = random.nextInt(characterSet.length);
			result[i] = characterSet[randomCharIndex];

		}
		return new String(result);
	}
	
	public static final String SEPARATOR = "@";

	public String gerarHash() {
		String hash = UUID.randomUUID().toString();
		long millis = Calendar.getInstance().getTimeInMillis();
		hash = millis + SEPARATOR + hash;
		return hash;
	}

}
